var oBtn = document.querySelector("button");
var oDiv = document.querySelector("div");

function close() {
  if (oDiv.style.display == "none") {
    oDiv.style.display = "block";
    document.querySelector("body").style.backgroundColor = "rgba(0,0,0,.5)";
  } else {
    oDiv.style.display = "none";
    document.querySelector("body").style.backgroundColor = "white";
  }
}

oBtn.onclick = function () {
  close();
}

var closeIcon = document.querySelector(".close");
closeIcon.onclick = function () {
  close();
}

var closeBtn = document.querySelector(".closeBtn");
closeBtn.onclick = function () {
  close();
}

var login = document.querySelector("#login");
var username = document.querySelector("#name");
var password = document.querySelector("#pwd");

login.onclick = function () {
  if (username.value == "" && password.value != "") {
    alert("登录失败，请输入Username:");
    username.value = "";
    password.value = "";
  } else if (password.value == "" && username.value != "") {
    alert("登录失败，请输入Password:");
    username.value = "";
    password.value = "";
  } else if (username.value == "" && password.value == "") {
    alert("登录失败，请输入Username 和 Password:");
    username.value = "";
    password.value = "";
  } else {
    alert("恭喜您，登录成功！");
    username.value = "";
    password.value = "";
  }
}